package splitNum;


import java.util.ArrayList;
import java.util.Comparator;

public class Solution {
    public int splitNum(int num) {
        // 分成两个字符串
        ArrayList<Integer>list=new ArrayList<>();
        while(num>0){
            list.add(num%10);
            num/=10;
        }
        list.sort(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });
        System.out.println(list);
        int res1=0;
        int res2=0;
        int n=0;
        for (int i = 0; i+1<list.size() ; i+=2) {
            res1+= Math.pow(10,n)*list.get(i);
            res2+=Math.pow(10,n)*list.get(i+1);
            n++;
        }
        System.out.println(res1+" "+res2);
        return res1+res2;
    }
}